﻿<!DOCTYPE html>
<!--stop信息管理 bysongyf-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <link href="/static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="/static/js/vue-treeselect/vue-treeselect.js"></script>

    <style>
        .vue-treeselect__control {
            height: 100%;
            border: none;
            background: none;
        }

        .vue-treeselect__placeholder {
            top: -3px;
        }

        .vue-treeselect__single-value {
            top: -3px;
        }

        .el-input__suffix {
            z-index: 9;
        }

        #tcw0 .el-input__suffix {
            z-index: 10;
        }
    </style>
    <style>
        h3 {
            text-align: center
        }

        table {
            width: 100%;
            border-top: 0px solid;
            border-left: 0px solid;
            text-align: center;
        }

            table td,
            table th {
                border-right: 0px solid;
                border-bottom: 0px solid;
                border: 1px solid #dcdcdc;
                padding: 10px;
            }

        .el-checkbox-main .el-checkbox {
            display: flex;
            margin: 5px 0 0 0;
            /* float: left; */
            white-space: inherit;
        }

            .el-checkbox-main .el-checkbox .el-checkbox__input {
                top: 4px
            }

            .el-checkbox-main .el-checkbox span,
            .el-checkbox-main .el-checkbox__label {
                float: left;
            }

        .el-checkbox-main div {
            /* width: 200px; */
            margin: auto
        }

        .align-left {
            text-align: left
        }

        .dian {
            width: 2px;
            height: 2px;
            background-color: #fff;
            display: inline-block;
            margin: 0 10px 4px 0;
        }

        .dianblack {
            width: 2px;
            height: 2px;
            background-color: #000000;
            display: inline-block;
            margin: 0 10px 4px 0;
        }

        .th-bgc {
            background-color: #d24b45;
        }

        .tit-bgc {
            background-color: #c3c2c0;
        }

        th {
            color: #fff;
        }
    </style>



    <script>
        
    </script>
</head>


<body>
    <div id="app" v-cloak class="popupW100">
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px"
                 size="mini">
            <el-row>
                <table id="table1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; float: left; width: 50%; height: 1400px">
                    <tr>
                        <td colspan="2">
                            <h1>STOP安全观察流程</h1>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <img src="/static/images/stop.jpg" alt=""
                                 style="width: 100%;height: auto;max-width: 500px;">
                        </td>
                    </tr>
                    <tr class="tit-bgc">
                        <td colspan="2">
                            <h3>STOP审核检查表</h3>
                        </td>
                    </tr>
                    <tr>
                        
                        <td>
                            <div>
                                <div style="width:inherit;text-align:left;display:inline;float:left">
                                    若有任何不安全<br><el-checkbox style="margin-right:4px" disabled></el-checkbox>请勾选
                                </div>
                                <div style="width:inherit;text-align:right;display:inline;float:right">
                                    若所有皆安全<br>请勾选<el-checkbox style="margin-left:4px" disabled></el-checkbox>
                                </div>
                            </div>
                        </td>
                        <td>
                            <div>
                                <div style="width:inherit;text-align:left;display:inline;float:left">
                                    若有任何不安全<br><el-checkbox style="margin-right:4px" disabled></el-checkbox>请勾选
                                </div>
                                <div style="width:inherit;text-align:right;display:inline;float:right">
                                    若所有皆安全<br>请勾选<el-checkbox style="margin-left:4px" disabled></el-checkbox>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th class="th-bgc">
                            <div style="width:auto;display:inline;text-align:center">{{bigTypeList.ryfy}}</div>
                            <div style="display:inline;float:right"><el-checkbox class="ml10" v-model="Form.ryfy_IsSafety" @change="checked=>checkBigType(checked, 'ryfy')"></el-checkbox></div>
                        </th>
                        <th class="th-bgc">
                            <div style="width:auto;display:inline;text-align:center">{{bigTypeList.grfhzb}}</div>
                            <div style="display:inline;float:right"><el-checkbox class="ml10" v-model="Form.grfhzb_IsSafety" @change="checked=>checkBigType(checked, 'grfhzb')"></el-checkbox></div>

                            
                        </th>
                    </tr>
                    <tr>
                        <td class="el-checkbox-main">
                            <el-row v-for="item in Form.ryfyCheckList">
                                <el-col>
                                    <el-checkbox v-model="item.isNotSafe" @change="checked=>checkSmallType(checked,'ryfy')">{{item.smallTypeText}}</el-checkbox>
                                </el-col>
                            </el-row>

                            <el-checkbox v-model="Form.ryfyInput1.isNotSafe" @change="checked=>checkSmallType(checked,'ryfy')">
                                <el-input size="mini" v-model="Form.ryfyInput1.smallTypeText" placeholder="请输入内容"></el-input>
                            </el-checkbox>
                            <el-checkbox v-model="Form.ryfyInput2.isNotSafe" @change="checked=>checkSmallType(checked,'ryfy')">
                                <el-input size="mini" v-model="Form.ryfyInput2.smallTypeText" placeholder="请输入内容"></el-input>
                            </el-checkbox>
                        </td>
                        <td class="el-checkbox-main">
                            
                            <el-row v-for="item in Form.grfhzbCheckList">
                                <el-col>
                                    <el-checkbox v-model="item.isNotSafe" @change="checked=>checkSmallType(checked,'grfhzb')">{{item.smallTypeText}}</el-checkbox>
                                </el-col>
                            </el-row>


                            <el-checkbox v-model="Form.grfhzbInput1.isNotSafe" @change="checked=>checkSmallType(checked,'grfhzb')">
                                <el-input size="mini" v-model="Form.grfhzbInput1.smallTypeText" placeholder="请输入内容"></el-input>
                            </el-checkbox>
                            <el-checkbox v-model="Form.grfhzbInput2.isNotSafe" @change="checked=>checkSmallType(checked,'grfhzb')">
                                <el-input size="mini" v-model="Form.grfhzbInput2.smallTypeText" placeholder="请输入内容"></el-input>
                            </el-checkbox>
                        </td>
                    </tr>
                    <tr>
                        <th class="th-bgc">
                            <div style="width:auto;display:inline;text-align:center">{{bigTypeList.rydwz}}</div>
                            <div style="display:inline;float:right">
                            <el-checkbox class="ml10" v-model="Form.rydwz_IsSafety" @change="checked=>checkBigType(checked, 'rydwz')"></el-checkbox>
                            </div>

                            
                        </th>
                        <th class="th-bgc">
                            <div style="width:auto;display:inline;text-align:center">{{bigTypeList.gjjsb}}</div>
                            <div style="display:inline;float:right">
                                <el-checkbox class="ml10" v-model="Form.gjjsb_IsSafety" @change="checked=>checkBigType(checked, 'gjjsb')"></el-checkbox>
                            </div>
                            
                        </th>
                    </tr>
                    <tr>
                        
                        <td class="el-checkbox-main">
                            伤害的原因
                            <el-row v-for="item in Form.rydwzCheckList">
                                <el-col>
                                    <el-checkbox v-model="item.isNotSafe" @change="checked=>checkSmallType(checked,'rydwz')">{{item.smallTypeText}}</el-checkbox>
                                </el-col>
                            </el-row>


                            <el-checkbox v-model="Form.rydwzInput1.isNotSafe" @change="checked=>checkSmallType(checked,'rydwz')">
                                <el-input size="mini" v-model="Form.rydwzInput1.smallTypeText" placeholder="请输入内容"></el-input>
                            </el-checkbox>
                            <el-checkbox v-model="Form.rydwzInput2.isNotSafe" @change="checked=>checkSmallType(checked,'rydwz')">
                                <el-input size="mini" v-model="Form.rydwzInput2.smallTypeText" placeholder="请输入内容"></el-input>
                            </el-checkbox>

                        </td>
                        <td class="el-checkbox-main">
                            <el-row v-for="item in Form.gjjsbCheckList">
                                <el-col>
                                    <el-checkbox v-model="item.isNotSafe" @change="checked=>checkSmallType(checked,'gjjsb')">{{item.smallTypeText}}</el-checkbox>
                                </el-col>
                            </el-row>


                            <el-checkbox v-model="Form.gjjsbInput1.isNotSafe" @change="checked=>checkSmallType(checked,'gjjsb')">
                                <el-input size="mini" v-model="Form.gjjsbInput1.smallTypeText" placeholder="请输入内容"></el-input>
                            </el-checkbox>

                        </td>
                    </tr>
                    <tr>
                        <th class="th-bgc">
                            <div style="width:auto;display:inline;text-align:center">{{bigTypeList.cx}}</div>
                            <div style="display:inline;float:right">
                                <el-checkbox class="ml10" v-model="Form.cx_IsSafety" @change="checked=>checkBigType(checked, 'cx')"></el-checkbox>
                            </div>
                            
                        </th>
                        <th class="th-bgc">
                            <div style="width:auto;display:inline;text-align:center">{{bigTypeList.zxbz}}</div>
                            <div style="display:inline;float:right">
                                <el-checkbox class="ml10" v-model="Form.zxbz_IsSafety" @change="checked=>checkBigType(checked, 'zxbz')"></el-checkbox>
                            </div>
                            
                        </th>
                    </tr>
                    <tr>
                        <td class="el-checkbox-main">
                            <el-row v-for="item in Form.cxCheckList">
                                <el-col>
                                    <el-checkbox v-model="item.isNotSafe" @change="checked=>checkSmallType(checked,'cx')">{{item.smallTypeText}}</el-checkbox>
                                </el-col>
                            </el-row>
                            <el-checkbox v-model="Form.cxInput1.isNotSafe" @change="checked=>checkSmallType(checked,'cx')">
                                <el-input size="mini" v-model="Form.cxInput1.smallTypeText" placeholder="请输入内容"></el-input>
                            </el-checkbox>
                        </td>
                        <td class="el-checkbox-main">
                            <el-row v-for="item in Form.zxbzCheckList">
                                <el-col>
                                    <el-checkbox v-model="item.isNotSafe" @change="checked=>checkSmallType(checked,'zxbz')">{{item.smallTypeText}}</el-checkbox>
                                </el-col>
                            </el-row>
                            <el-checkbox v-model="Form.zxbzInput1.isNotSafe" @change="checked=>checkSmallType(checked,'zxbz')">
                                <el-input size="mini" v-model="Form.zxbzInput1.smallTypeText" placeholder="请输入内容"></el-input>
                            </el-checkbox>
                        </td>
                    </tr>
                </table>
                <table id="table2" cellpadding="0" cellspacing="0"
                       style="border-collapse:collapse;text-align: left;float:left;margin-left: -1px;width: 50%;height:1400px">
                    <tr>
                        <td colspan="2">
                            <h3 style="padding: 10px 0;">完成观察报告</h3>
                        </td>
                    </tr>
                    <tr>
                        <th class="align-left th-bgc">
                            环境
                        </th>
                    </tr>
                    <tr>
                        <td>
                            
                            <p class="fl">
                                <span class="dianblack"></span>工具和设备
                            </p>
                            <p class="fl ml10">
                                <span class="dianblack"></span>环境
                            </p>
                            <p class="fl ml10">
                                <span class="dianblack"></span>结构与工作区域
                            </p>
                            <p class="fl ml10">
                                <span class="dianblack"></span>秩序
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <th class="align-left th-bgc">
                            <p><span class="dian"></span>观察到的安全行为</p>
                            <p><span class="dian"></span>为鼓励持续的安全表现所采取的行动</p>
                        </th>
                    </tr>
                    
                    <tr>
                        <td>
                            <el-form-item prop="encourage">
                                <el-input size="mini" placeholder="请输入内容" v-model="Form.encourage" type="textarea" rows="15">
                                </el-input>
                                <span class="iputLineMust" v-if="!Form.encourage">
                                    <img src="/static/images/exclamation.png" alt="">
                                </span>
                            </el-form-item>
                        </td>
                    </tr>
                    <tr>
                        <th class="align-left th-bgc">
                            <p><span class="dian"></span>观察到的不安全行为</p>
                            <p><span class="dian"></span>立即采取的纠正措施</p>
                            <p><span class="dian"></span>预防再次发生采取的措施</p>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <el-form-item prop="correct">
                                <el-input size="mini" placeholder="请输入内容" v-model="Form.correct" type="textarea" rows="15">
                                </el-input>
                                <span class="iputLineMust" v-if="!Form.encourage">
                                    <img src="/static/images/exclamation.png" alt="">
                                </span>
                            </el-form-item>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding: 18px 10px 19px 10px;">
                            <!--<el-col :span="24">
                                <div class="elst-select-mini">
                                    <el-form-item prop="observePeople">
                                        <el-input size="mini" style="z-index:200">
                                            <template slot="prepend">
                                                {{STOPInformationManagement.observePeople+mark.m}}
                                            </template>
                                            <tree-department-staff-single-jgstop slot="suffix" v-model="Form.observePeople" style="line-height:28px;"></tree-department-staff-single-jgstop>
                                        </el-input>
                                        <span class="iputLineMust" v-if="!Form.observePeople" style="z-index:201">
                                            <img src="/static/images/exclamation.png" alt="">
                                        </span>
                                    </el-form-item>
                                </div>
                            </el-col>-->
                            <el-col :span="24">
                                <div class="elst-select-mini">
                                    <el-form-item prop="shifts">
                                        <el-input size="mini">
                                            <template slot="prepend">
                                                <div>{{STOPInformationManagement.shifts+mark.m}}</div>
                                            </template>
                                            <el-select @visible-change="visibleChange" v-model="Form.shifts" slot="suffix"
                                                       :placeholder="STOPInformationManagement.shifts">
                                                <el-option label="请选择" value=""></el-option>
                                                <el-option v-for="item in shifts" :label="item.value" :value="item.key">
                                                </el-option>
                                            </el-select>
                                        </el-input>
                                        <span class="iputLineMust" v-if="!Form.shifts">
                                            <img src="/static/images/exclamation.png" alt="">
                                        </span>
                                    </el-form-item>
                                </div>
                            </el-col>

                            <el-col :span="24">
                                <div class="elst-select-mini">
                                    <el-form-item prop="situation">
                                        <el-input size="mini" style="z-index:100">
                                            <template slot="prepend">
                                                <div>{{STOPInformationManagement.situation+mark.m}}</div>
                                            </template>
                                            <treeselect v-model="Form.situation" :options="areaList" :flat="true" slot="suffix"
                                                        style="line-height: 28px;width:70%;" :disable-branch-nodes="true"
                                                        placeholder="请选择区域" />

                                        </el-input>
                                        <span class="iputLineMust" v-if="!Form.situation" style="z-index:101">
                                            <img src="/static/images/exclamation.png" alt="">
                                        </span>
                                    </el-form-item>
                                </div>
                            </el-col>
                            <el-col :span="24">
                                <el-form-item prop="observaDate">
                                    <div class="elst-select-mini">
                                        <el-input size="mini">
                                            <template slot="prepend">
                                                {{STOPInformationManagement.observaDate+mark.m}}
                                            </template>
                                            <el-date-picker slot="suffix" v-model="Form.observaDate" type="datetime"
                                                            size="mini" placeholder="选择日期">
                                            </el-date-picker>
                                        </el-input>
                                        <span class="iputLineMust" v-if="!Form.observaDate">
                                            <img src="/static/images/exclamation.png" alt="">
                                        </span>
                                    </div>
                                </el-form-item>
                            </el-col>
                            <el-col :span="24">
                                <div class="elst-select-mini">
                                    <el-form-item prop="observation">
                                        <el-input size="mini" v-model="Form.observation">
                                            <template slot="prepend">
                                                {{STOPInformationManagement.observation+mark.m}}
                                            </template>

                                        </el-input>
                                        <span class="iputLineMust" v-if="!Form.observation">
                                            <img src="/static/images/exclamation.png" alt="">
                                        </span>
                                    </el-form-item>
                                </div>
                            </el-col>
                            
                        </td>
                    </tr>
                </table>
            </el-row>
            <br>
            <el-row type="flex" justify="end">
                <el-form-item style="text-align:center; padding-top:5px">
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnCommit}}</el-button>
                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                </el-form-item>
                <br><br><br>
            </el-row>
        </el-form>
    </div>
    <script type="text/javascript">
        Vue.component('treeselect', VueTreeselect.Treeselect)
        app = new Vue({
            el: '#app',
            data: {
                id: '',             //列表页传参
                factoryId: '',      //当前用户工厂
                areaList: [],       //区域下拉列表数据源
                shifts: [],         //班次下拉列表数据源

                //大类型名称绑定
                bigTypeList: {
                    ryfy: '',       //人员的反应
                    grfhzb: '',     //个人防护装备
                    rydwz: '',      //人员的位置
                    gjjsb: '',      //工具及设备
                    cx: '',         //程序
                    zxbz: ''        //秩序标准
                },
                Form: {

                    ryfyCheckList: [{ isNotSafe: false, smallTypeText: '' }],   //人员的反应小类型复选框们
                    ryfyInput1: { isNotSafe: false, smallTypeText: '' },        //人员反应自定义输入框1
                    ryfyInput2: { isNotSafe: false, smallTypeText: '' },        //人员反应自定义输入框2

                    grfhzbCheckList: [{ isNotSafe: false, smallTypeText: '' }], //个人防护小类型复选框们
                    grfhzbInput1: { isNotSafe: false, smallTypeText: '' },      //个人防护装备输入框1
                    grfhzbInput2: { isNotSafe: false, smallTypeText: '' },      //个人防护装备输入框2

                    rydwzCheckList: [{ isNotSafe: false, smallTypeText: '' }],  //人员的位置小类型复选框们
                    rydwzInput1: { isNotSafe: false, smallTypeText: '' },       //人员的位置输入框1
                    rydwzInput2: { isNotSafe: false, smallTypeText: '' },       //人员的位置输入框2

                    gjjsbCheckList: [{ isNotSafe: false, smallTypeText: '' }],  //工具及设备小类型复选框们
                    gjjsbInput1: { isNotSafe: false, smallTypeText: '' },       //工具及设备输入框

                    cxCheckList: [{ isNotSafe: false, smallTypeText: '' }],     //程序小类型复选框们
                    cxInput1: { isNotSafe: false, smallTypeText: '' },          //程序输入框

                    zxbzCheckList: [{ isNotSafe: false, smallTypeText: '' }],   //秩序标准小类型复选框们
                    zxbzInput1: { isNotSafe: false, smallTypeText: '' },        //秩序标准输入框


                    encourage: '',          //观察到的安全行为；为鼓励持续的安全表现所采取的行动
                    correct: '',            //观察到的不安全行为；立即采取的纠正措施；预防再次发生采取的措施
                    observation: '',        //观察时长
                    situation: null,        //区域
                    observePeople: null,    // "观察人",
                    shifts: null,           //"班次",
                    department: null,       //部门
                    ryfy_IsSafety: false,   //人员反应大类复选框是否勾选
                    grfhzb_IsSafety: false, //个人防护装备大类复选框是否勾选
                    rydwz_IsSafety: false,  //人员的位置大类复选框是否勾选
                    gjjsb_IsSafety: false,  //工具及设备大类复选框是否勾选
                    cx_IsSafety: false,     //程序大类复选框是否勾选
                    zxbz_IsSafety: false,   //秩序标准大类复选框是否勾选
                    CreateFactory:'',       //隶属工厂

                    id: guidEmpty,          //记录ID
                },
                //表单验证
                rules: {
                    observePeople: [verification.NotNullSelect],
                    observation: [verification.NotNull],
                    shifts: [verification.NotNullSelect],
                    situation: [verification.NotNullSelect],
                    observaDate: [verification.NotNull],
                    encourage: [verification.NotNull],
                    correct: [verification.NotNull]
                },

                ListItem: ListItem,         //框架要求必须存在的项，否则无法控制loading画面
            },
            methods: {

                //当点击小类型复选框时触发，大类型下的小类型只要有一个被选中，大类型就不能被选中
                //因为大类型表示所有小类型都安全，大类型选中表示所有小类型都不选中
                //小类型选中表示不安全，有一项不安全，大类型就不安全
                checkSmallType(checked, item) {
                    if (checked == true) {
                        switch (item) {
                            case 'ryfy': this.Form.ryfy_IsSafety = false; break;
                            case 'grfhzb': this.Form.grfhzb_IsSafety = false; break;
                            case 'rydwz': this.Form.rydwz_IsSafety = false; break;
                            case 'gjjsb': this.Form.gjjsb_IsSafety = false; break;
                            case 'cx': this.Form.cx_IsSafety = false; break;
                            case 'zxbz': this.Form.zxbz_IsSafety = false; break;
                            default: break;
                        }
                    }
                },

                //只要大类型被选中，就将它下面的所有小类型设置为不选中
                checkBigType(checked, item) {
                    var value = !checked;
                    switch (item) {
                        case 'ryfy': {
                            target = this.Form.ryfyCheckList;
                            if (checked == true) {
                                this.Form.ryfyInput1.isNotSafe = false;
                                this.Form.ryfyInput2.isNotSafe = false;
                            }
                            break;
                        }
                        case 'grfhzb': {
                            target = this.Form.grfhzbCheckList;
                            if (checked == true) {
                                this.Form.grfhzbInput1.isNotSafe = false;
                                this.Form.grfhzbInput2.isNotSafe = false;
                            }
                            break;
                        }
                        case 'rydwz': {
                            target = this.Form.rydwzCheckList;
                            if (checked == true) {
                                this.Form.rydwzInput1.isNotSafe = false;
                                this.Form.rydwzInput2.isNotSafe = false;
                            }
                            break;
                        }
                        case 'gjjsb': {
                            target = this.Form.gjjsbCheckList;
                            if (checked == true) {
                                this.Form.gjjsbInput1.isNotSafe = false;
                            }
                            break;
                        }
                        case 'cx': {
                            target = this.Form.cxCheckList;
                            if (checked == true) {
                                this.Form.cxInput1.isNotSafe = false;
                            }
                            break;
                        }
                        case 'zxbz': {
                            target = this.Form.zxbzCheckList;
                            if (checked == true) {
                                this.Form.zxbzInput1.isNotSafe = false;
                            }
                            break;
                        }
                        default: break;
                    }

                    target.forEach(i => {
                        if (checked == true) {
                            i.isNotSafe = false;
                        }
                    });

                },

                //框架自动添加的内容
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                handleNodeClick: function (data) {
                    console.log(data);
                },
                handleSelect: function (ev) {
                    console.log(ev);
                },
                handleChecked: function (value) {
                },
                handleCheckedConfirmation: function (value) {
                },
                deleteRow: function (index, rows) {
                    rows.splice(index, 1);
                },

                //获取记录数据
                getData: function () {

                    getData(this, '/api/JG_STOPObserveMain/get?id=' + this.id);
                },

                //提交数据
                onSubmitForm: function (formName) {
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            var mythis = this;
                            //先获得选中的用户所在的部门
                            //syftodo 其实在后台做比较好
                            //myAjax("get", mythis, "/api/JG_STOPObserveMain/GetUserDepartment?id=" + mythis.Form.observePeople, null, function (response) {
                            //    var result = response.data;
                            //    mythis.Form.department = result;

                            //}, false);
                            onSubmitForm(this, '/api/JG_STOPObserveMain/Save', mythis.Form);
                        } else {
                            return false;
                        }
                    });
                },

                //获得大类型列表
                getBigTypeList() {
                    var mythis = this;
                    myAjax("get", this, "/api/JG_STOPObserveMain/GetBigTypeList", null, function (response) {
                        var result = response.data;
                        mythis.bigTypeList = result;
                    }, false);
                },
                //获得默认的小类型列表
                getSmallTypeList() {
                    //事实上，每一个小类型是一个ObserveDetail的实例
                    var mythis = this;
                    myAjax("get", this, "/api/JG_STOPObserveMain/GetSmallTypeList", null, function (response) {
                        var result = response.data;

                        //复选框组，是循环自动生成的
                        mythis.Form.ryfyCheckList = [];
                        mythis.Form.ryfyCheckList = result.ryfyDetailList;

                        mythis.Form.grfhzbCheckList = [];
                        mythis.Form.grfhzbCheckList = result.grfhzbDetailList;

                        mythis.Form.rydwzCheckList = [];
                        mythis.Form.rydwzCheckList = result.rydwzDetailList;

                        mythis.Form.gjjsbCheckList = [];
                        mythis.Form.gjjsbCheckList = result.gjjsbDetailList;

                        mythis.Form.cxCheckList = [];
                        mythis.Form.cxCheckList = result.cxDetailList;

                        mythis.Form.zxbzCheckList = [];
                        mythis.Form.zxbzCheckList = result.zxbzDetailList;

                        //输入框，是写死的
                        mythis.Form.ryfyInput1 = {};
                        mythis.Form.ryfyInput1 = result.ryfyInput1;
                        mythis.Form.ryfyInput2 = {};
                        mythis.Form.ryfyInput2 = result.ryfyInput2;

                        mythis.Form.grfhzbInput1 = {};
                        mythis.Form.grfhzbInput1 = result.grfhzbInput1;
                        mythis.Form.grfhzbInput2 = {};
                        mythis.Form.grfhzbInput2 = result.grfhzbInput2;

                        mythis.Form.rydwzInput1 = {};
                        mythis.Form.rydwzInput1 = result.rydwzInput1;
                        mythis.Form.rydwzInput2 = {};
                        mythis.Form.rydwzInput2 = result.rydwzInput2;

                        mythis.Form.gjjsbInput1 = {};
                        mythis.Form.gjjsbInput1 = result.gjjsbInput1;

                        mythis.Form.cxInput1 = {};
                        mythis.Form.cxInput1 = result.cxInput1;

                        mythis.Form.zxbzInput1 = {};
                        mythis.Form.zxbzInput1 = result.zxbzInput1;

                    }, false);

                },

                //获得区域列表
                GetAreaList: function (type) {
                    var mythis = this;
                    myAjax("post", this, '/api/SysArea/GetList', { model: { Name: '', Code: '', SubFactory: this.factoryId }, offset: 0, limit: 999 }
                        , function (response) {
                            
                            mythis.areaList = menuHelper(response.data.pageData, null);
                            
                        },
                        false);
                },

                //获得当前用户所在的工厂
                GetCurrentUserFactory: function () {
                    var mythis = this;
                    myAjax("get", this, "/api/JG_STOPObserveMain/GetCurrentUserFactory", null, function (response) {
                        mythis.factoryId = response.data;
                        mythis.Form.CreateFactory = response.data;
                    }, false);
                }
            },
            mounted: function () {

                //获得当前用户所在工厂
                this.GetCurrentUserFactory();
                //绑定区域下拉列表
                this.GetAreaList();
                //绑定大类型文字
                this.getBigTypeList();
                this.id = getUrlParam("id");
                if (this.id != null) {
                    var mythis = this;
                    if (mythis.id != null && mythis.id != '') {
                        myAjax("get", mythis, '/api/JG_STOPObserveMain/get?id=' + this.id, null, function (response) {
                            var ajaxModel = response.data;
                            mythis.Form = ajaxModel;
                        }, false);
                    }
                }
                else {
                    //添加的时候，绑定默认的小类型
                    this.getSmallTypeList();
                }
                this.shifts = getDicData('n51');//绑定班次下拉列表
                
            }
        });

        //下拉树数据格式化
        function menuHelper(list, pid) {

            var result = [];
            if (list.length <= 0)
                return list;
            list.forEach(function (v, i) {
                var temp = {};
                for (var key in v) {
                    temp[key] = v[key];
                }
                temp.label = v.name;
                //temp.parentId = temp.parentId ? temp.parentId : guidEmpty;
                var obj;
                if (temp.parentId == pid) {
                    obj = temp;
                    var nextObj = menuHelper(list, temp.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }

        function fnCommon_parentId(data, pid) {
            var result = [],
                temp;
            data.forEach(function (v, i) {
                if (!v.parentId) v.parentId = guidEmpty;
                if (v.parentId == pid) {
                    //debugger
                    var obj = v;
                    for (var key in v) {
                        obj[key] = v[key];
                    }
                    obj.icon = 'tree-item';
                    temp = this.fnCommon_parentId(data, data[i].id);
                    if (temp.length > 0) {
                        obj.children = temp;
                        obj.icon = 'tree-open';
                    }
                    result.push(obj);
                }
            })
            return result
        }

Vue.component('tree-department-staff-single-jgstop', {
            props: ['value', 'multiple'],
            data: function () {
                return {
                    options: [],
                    valueConsistsOf: "LEAF_PRIORITY"
                }
            },
            methods: {
                input: function (v, instanceId) {
                    console.log(v);
                    this.$emit('input', v);
                },
                getData: function () {
                    var app = this;
                    myAjax("Get", null, "/api/JG_STOPObserveMain/GetTreeDepartmentStaff", null, function (response) {
                        var ajaxModel = response.data;
                        app.options = PersonMenuHelper(ajaxModel, guidEmpty);
                    }, false);
                }
            },
            mounted: function () {
                this.getData();
            },
            template: ' <treeselect :multiple="multiple"     :disable-branch-nodes="true"   :value-consists-of="valueConsistsOf"  :options="options"    v-model="value" @input="input"  />'

        })


    </script>
</body>

</html>